/**
 * ResponseHeaderFilter.java
 */
package com.navidove.web.filter;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.filter.OncePerRequestFilter;

/**
 * ResponseHeaderFilter
 *
 * @author $Author$
 * @version $Revision$
 * @date $Date$
 * @url $URL$
 */
public class ResponseHeaderFilter extends OncePerRequestFilter {

	/**
	 * @see org.springframework.web.filter.OncePerRequestFilter#doFilterInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)
	 */
	protected void doFilterInternal(HttpServletRequest request,
			HttpServletResponse response, FilterChain filterChain)
			throws ServletException, IOException {

		@SuppressWarnings("unchecked")
		Enumeration<String> names = getFilterConfig().getInitParameterNames();
		while(names.hasMoreElements()){
			String name = names.nextElement();
			response.setHeader(name, getFilterConfig().getInitParameter(name));
		}		

		doFilter(request, response, filterChain);
	}

}
